<?php
namespace app\admin\command;

use think\Config;
use think\console\Command;
use think\console\Input;
use think\console\input\Option;
use think\console\Output;
use think\Exception;
use fast\Http;
use think\Db;

class Usdt extends Command
{
    protected function configure()
    {
        $this->setName('usdt')->setDescription('USDT价格采集');
    }

    protected function execute(Input $input, Output $output)
    {
    	$Http = new \fast\Http;
        $result = $Http->get('http://api.zb.cn/data/v1/trades?market=usdt_qc');
        $result = json_decode($result,true);
        $item = $result[0];
        Db::name('config')->where(['group'=>'exchange','name'=>'usdt'])->update([
            'value'=>round($item['price'],2)
        ]);
        $output->writeln('USDT最新售价：'.$item['price']);
    }
}